package com.icehand.json.utils;

import net.sf.json.JSONObject;

/**
 * json-lib
 * @author zhoujunmei
 * @date 2019-08-02 10:31
 * @remark
 */
public class JsonLibUtil {
    public static String toJSONString(Object object) {
        JSONObject jsonObject = JSONObject.fromObject(object);
        return jsonObject.toString();
    }

    @SuppressWarnings("unchecked")
    public static <T> T toObject(String string, Class<T> clazz) {
        return (T) JSONObject.toBean(JSONObject.fromObject(string),clazz);
    }
}
